package com.xiaoyu.seata.config;

import com.alibaba.cloud.seata.web.SeataHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * <p>
 * Swagger 配置
 * </p>
 *
 * @author zgb   Email: 1021180632@qq.com
 * @since 2020/10/9 10:41
 */

@Configuration
public class SeataConfig extends WebMvcConfigurationSupport {

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        //如果微服务实现了 WebMvcConfigurationSupport，SpringCloud xid无法传递
        //把SeataHandlerInterceptor加入到你的拦截链路中，避免Seata不回滚
        registry.addInterceptor(new SeataHandlerInterceptor()).addPathPatterns("/**");
    }
}
